package acwing.数组;

import java.util.Scanner;

/**
 * 删除数组零元素
 *
 * @author yang
 * @date 2021/12/17
 */
public class 删除数组零元素 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        int sum = 0;
        int j = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            if (arr[i] != 0) sum++;
        }
        System.out.println(sum);
        for (int i = 0; i < n; i++) {
            if (arr[i] != 0) {
                System.out.print(arr[i] + " ");
            }
        }
    }
}
